package com.isoft.hospital.dao;

import com.isoft.hospital.entity.Medicine;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface MedicineDao {
    @Insert("insert into medicine(m_id,m_name,c_time,r_time,stock,valid,price) value(#{m_id},#{m_name},#{c_time},#{r_time},#{stock},#{valid},#{price}) ")
    int insertMedicine(Medicine medicine);
    @Select("select m_id,m_name,c_time,r_time,stock,valid,price from medicine")
    List<Medicine> findAllMedicine();
    @Select("select m_id,m_name,c_time,r_time,stock,valid,price from medicine where m_id=#{m_id} ")
    Medicine findByMid(@Param("m_id") int m_id);
    @Update("update medicine set c_time=#{c_time},stock=#{stock} where m_id=#{m_id}")
    int updateMedicine(Medicine medicine);
    @Select("select stock from medicine where m_id=#{m_id}")
    Medicine getStock(String mid);
    @Delete("delete from medicine where m_id=#{m_id}")
    int deleteMedicine(int m_id);
    @Select("select m_name,stock from medicine")
    List<Medicine> queryMedicine();
}
